using System.Linq;
using TaskManager.Domain.BusinessObjects;
using TaskManager.Domain.Repositories;

namespace TaskManager.DataAccess.Repositories
{
    internal class ProjectRepository : Repository<Project, int>, IProjectRepository
    {
        private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ProjectRepository));

        public ProjectRepository(TaskManagerDbContext context) 
            : base(context, context.Projects)
        {
            if(Log.IsDebugEnabled) Log.Debug("Created ProjectRepository");
        }

        public Project FindByName(string name)
        {
            return All.Where(project => project.Name == name).SingleOrDefault();
        }
    }
}